angular.module("roster.router", ["ui.router"]);
angular.module("roster.controller", []);
angular.module("roster.directive", []);
var rosterApp = angular.module('cloap_roster_app', [
                          'ui.bootstrap', 'pascalprecht.translate',
                          'rosterService', 'rosterTranslate',
                          'checklist-model', "roster.router",
                          "roster.controller", "roster.directive"
                          ]);

rosterApp.config(function($httpProvider) {
    "use strict";

    //Enable cross domain calls
    $httpProvider.defaults.useXDomain = true;

    //Remove the header used to identify ajax call  that would prevent CORS from working
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
  });


rosterApp.config(function($stateProvider) {
    "use strict";

    $stateProvider
        .state("cloap_roster_app", {
          url: "/cloap_roster_app",
          templateUrl:  "/cloap/app/cloap_roster_app/partial/index.html",
          onEnter: function($location) {
              $location.path("/cloap_roster_app/employees");
          }

    });

});
/*

var app = angular.module('mainApp', ['ui.router', 'ui.router.state', 'ngGrid','checklist-model','ui.bootstrap',
                            'pmsService', 'ui.select2', 'treeControl', 'pascalprecht.translate']);
  app.config(
    function($stateProvider, $urlRouterProvider) {
      $stateProvider
      /*证书清单
      .state('dashboard', { 
        url: '/' 
      })
    })
app.directive('ngConfirmClick', [
  function(){
    return {
      link: function (scope, element, attr) {
        var msg = attr.ngConfirmClick || "你确定?";
        var clickAction = attr.confirmedClick;
        element.bind('click',function (event) {
          if ( window.confirm(msg) ) {
            scope.$eval(clickAction)
          }
        });
      }
    };
  }])

var INTEGER_REGEXP = /^\d*$/;
app.directive("integer", function () {
  return {
    require:"ngModel",//NgModelController
    link:function(scope,ele,attrs,ctrl) {
      ctrl.$parsers.unshift(function (viewValue) {//$parsers，View到Model的更新
        if(INTEGER_REGEXP.test(viewValue)) {
          ctrl.$setValidity("integer", true);
          return viewValue;
        }else {
          ctrl.$setValidity("integer", false);
          return undefined;
        }
      });
    }
  };
});
app.filter('getById', function() {
  return function(input, id) {
    var i=0, len=input.length;
    for (; i<len; i++) {
      if (+input[i].id == +id) {
        return input[i];
      }
    }
    return null;
  }
});

app.controller('AssignmentPosition', function($scope, $filter, Organization, Position){
  $scope.change = function(){
    $scope.positions = Organization.query_position_standard({id: $scope.position.organization_id});
  }
});

app.config(function($translateProvider) {
  $translateProvider.translations('zh', {
    normal: '正常',
    position_normal: '在岗'
  });
  $translateProvider.preferredLanguage('zh');
});

*/

